package frontend.model.admin;

import backend.model.admin.CommuterData;
import backend.model.admin.Employee;
import frontend.model.base.UIModel;

import java.util.Date;

public class CommuterDataUIModel implements UIModel<CommuterData> {

    private CommuterData commuterData;
    private Employee employee;
    private Date startDate;
    private Date endDate;

    public CommuterDataUIModel(Employee employee) {
        commuterData = new CommuterData();
        this.employee = employee;
        commuterData.setEmployee(employee);
    }

    public CommuterDataUIModel(CommuterData commuterData) {
        this.commuterData = commuterData;
    }

    @Override
    public CommuterData getDBModel() {
        return commuterData;
    }

    @Override
    public void populateDBModelFromFields() {
        commuterData.setStartDate(startDate);
        commuterData.setEndDate(endDate);
    }

    @Override
    public void populateFieldsFromDBModel() {
        this.employee = commuterData.getEmployee();
        this.startDate = commuterData.getStartDate();
        this.endDate = commuterData.getEndDate();
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
}
